package app.fugema.shop.main.goods.view;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.base.common.netBeanPackage.LiveDataWrapper;
import com.base.common.utils.UIUtils;
import com.base.common.view.base.BaseTitleActivity;
import com.base.common.viewmodel.BaseViewObserver;
import app.fugema.shop.R;
import app.fugema.shop.databinding.ActivityMiniShopInfoBinding;
import app.fugema.shop.main.goods.model.VShopInfoResult;
import app.fugema.shop.main.goods.vm.ShopVM;

/**
 * 店铺简介
 */
public class ShopInfoActivity extends BaseTitleActivity<ActivityMiniShopInfoBinding, ShopVM>
{
    //微店id
    private int shopId;

    public static void start(Context context , int shopId)
    {
        Intent intent = new Intent(context, ShopInfoActivity.class);
        intent.putExtra("shopId", shopId);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mini_shop_info);
    }

    @Override
    protected int getStatusBarColor()
    {
        return R.color.redColor;
    }

    @Override
    protected void initView()
    {
        setCloseImg(R.mipmap.ic_back_white);
        setTitle("");
    }


    @Override
    protected void initData(Intent intent)
    {
        shopId = intent.getIntExtra("shopId", 0);
        getShopInfo(shopId);
    }


    public void getShopInfo(int mShopId)
    {
        viewModel.getShopIntroduce(mShopId).observe(this, new BaseViewObserver<LiveDataWrapper<VShopInfoResult>>(viewUtils.getStateLayout()) {
            @Override
            protected void onSuccess(LiveDataWrapper<VShopInfoResult> data)
            {
                binding.setItem(data.data.getVShop());
                binding.executePendingBindings();
            }

            @Override
            public boolean isEmptyData(LiveDataWrapper<VShopInfoResult> data)
            {
                return  UIUtils.isEmpty( data.data.getVShop());
            }

        });
    }


}
